package com.zygh.questionnairesurvey.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.questionnairesurvey.entity.UserMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMenuMapper  extends BaseMapper<UserMenu> {

    @Select("<script> SELECT m.*,r.visual_scope FROM user_info u LEFT JOIN user_role r ON u.role_id=r.id LEFT JOIN  user_menu m ON \n" +
            "FIND_IN_SET(m.id,r.menu_id)  <where> u.user_name = #{username} AND m.serial = #{serial} " +
            "<if test='level != null '>AND m.level = #{level}</if> </where> </script>")
    List<UserMenu> findMenuByUser(@Param("username") String username,
                                  @Param("serial")Integer serial,
                                  @Param("level")Integer level);


	
}